package com.sjz.bookmark.setting;

import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.NlsContexts;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
 * 书签设置窗口
 *
 * @author shijinze
 */
public class BookmarkSettingForm implements Configurable {
    private JPanel mainPane;
    private JTextField mysqlHost;
    private JTextField mysqlPort;
    private JTextField mysqlUser;
    private JTextField mysqlPassword;
    private JTextField mysqlDb;

    private JLabel projectNameLabal;
    private JTextField projectIdLabal;
    private JTextField syncProjectId;
    private JTextArea remarkLabel;
    private JCheckBox showLogCheckBox;
    private JCheckBox userMysqlCheckBox;

    private GeneralSettings generalSettings;

    @Override
    public @NlsContexts.ConfigurableName String getDisplayName() {
        return "Bookmark Setting";
    }

    @Override
    public @Nullable JComponent createComponent() {
        // 初始化全局设置
        generalSettings = new GeneralSettings(mysqlHost,
                mysqlPort, mysqlUser, mysqlPassword,mysqlDb, projectNameLabal,projectIdLabal,
                syncProjectId,remarkLabel,showLogCheckBox,userMysqlCheckBox);
        generalSettings.initGeneralSettings();
        return this.mainPane;
    }

    @Override
    public boolean isModified() {
        return true;
    }

    @Override
    public void apply() throws ConfigurationException {

    }

    private void createUIComponents() {
        // TODO: place custom component creation code here
    }
}
